import 'babel-polyfill'
import 'classlist-polyfill'
import Vue from 'vue'
import axios from './router/axios'
import VueAxios from 'vue-axios'
import App from './App'
import './permission' // 权限
import './error' // 日志
import router from './router/router'
import store from './store'
import { loadStyle } from './util/util'
import * as urls from '@/config/env'
import { iconfontUrl, iconfontVersion } from '@/config/env'
import * as filters from './filters' // 全局filter
// 引入avue2.0的包
//import Avue from '@smallwei/avue/lib/avue.js'
//import '@smallwei/avue/lib/index.css'

//avue1.0 改造包
//import Avue from '@/components/avue/src/index.js'
// 引入avue的样式文件
//import '@/components/avue/packages/theme-chalk/lib/index.css'

//avue1.0
// import Avue from '@smallwei/avue/lib/index.js'
// import '@smallwei/avue/lib/theme-chalk/index.css'
import Avue from '@smallwei/avue';
import '@smallwei/avue/lib/index.css';
import ChcUi from '@/components/chc-ui'
import '@/components/chc-ui/styles/index.scss'
//import '@/components/chc/packages/theme-chalk/lib/index.css'

import basicContainer from './components/basic-container/main'
// 插件 json 展示
import vueJsonTreeView from 'vue-json-tree-view'

import { validatenull } from '@/util/validate'
import './styles/common.scss'
import extendStyle from './styles/extendStyle.scss'

//加载模块
import '@/modules/sys'
import vxeTable from '@/plugin/vxetable'
//require('./mock/mock.js')
Vue.prototype.validatenull = validatenull
Vue.prototype.autoHeight = function (v,ref){
  return v.$parent.$el.offsetHeight-v.$refs[ref].$el.offsetHeight+32
}
Vue.prototype.renderBoolean = function(row,value,label,column){
	if(value==true){
		row[column.prop]=true;
		return '<span class="'+(column.warning?'warningColor':'')+'">是</span>';
	}else{
		row[column.prop]=false;
		return '<span >否</span>';
	}
}


Vue.use(Avue, { menuType: 'text' })

Vue.use(router)

Vue.use(vueJsonTreeView)

Vue.use(VueAxios, axios)

Vue.use(ChcUi, {})
// 注册全局容器
Vue.component('basicContainer', basicContainer)
//Vue.component('dataGrid', DataGrid);

// 加载相关url地址
Object.keys(urls).forEach(key => {
  Vue.prototype[key] = urls[key]
})

//加载过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

// 动态加载阿里云字体库
iconfontVersion.forEach(ele => {
  loadStyle(iconfontUrl.replace('$key', ele))
})

Vue.config.productionTip = false
Vue.use(vxeTable)
//记录下当前路径，在permission.js中加载菜单并转向此路径
if ('\\404'!==window.$currentPath)
  window.$currentPath = router.history.getCurrentLocation()
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

